using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class EnemyBigCute : EnemyBasic
{
    public float reduceratio;
    Image healthbar;
    public int state;
    public GameObject bigcute;
    bool ins = false;
    // Start is called before the first frame update
    public  override void TakeDamage(float damage, int face, int repeltimes, float repeldistance, float stifftime)
    {
        health -= (1- reduceratio)*damage;
        playerbasic.Recovery((1-reduceratio)*damage * playerbasic.healthrecoveryratio);
        healthbar.fillAmount = health / maxhealth;
        if (health <= 0)
        {

            stifftimeex = 999999;
            animator.SetTrigger("die");
            Invoke("Killplayer", dietime);
        }
        if (state == 1&&health<=maxhealth*0.5&&ins==false)
        {
            ins = true;
            Debug.Log("ojbk");
            Instantiate(bigcute, transform.position, Quaternion.identity);
            GameObject.Find("BigFish2(Clone)").GetComponent<EnemyBasic>().health = health;
            Destroy(gameObject);

        }
        //StartCoroutine(Stiff());
    }
    private void Start()
    {
        base.Start();
        maxhealth *=EnemyData.healthratio;
        if(state==2) health/= EnemyData.healthratio;
        healthbar = transform.GetChild(4).GetChild(0).GetComponent<Image>();
    }
    void  Update()
    {
        getplayer();
        if (moveable) {
            Move();
            Flip();
        }
        if (transform.position.y < -20f)
        {
            Killplayer();
        }
        if (transform.localRotation == Quaternion.Euler(0, 180, 0))
        {
            healthbar.transform.localRotation = Quaternion.Euler(0, 180, 0);
        }
        else healthbar.transform.localRotation = Quaternion.Euler(0, 0, 0);
    }
}
